package com.oop.demo09;

public class Application {
    public static void main(String[] args) {
        //Object --> Person --> Student
        //Object --> Person --> Teacher
        //Object --> String

        Object object = new Student();
        System.out.println(object instanceof Student);
        System.out.println(object instanceof Person);
        System.out.println(object instanceof Teacher);
        System.out.println(object instanceof Object);
        System.out.println(object instanceof String);

        System.out.println("=============");
        Person person = new Student();
        System.out.println(person instanceof Student);
        System.out.println(person instanceof Person);
        System.out.println(person instanceof Teacher);
        System.out.println(person instanceof Object);
//        System.out.println(person instanceof String);//编译就报错了；
        System.out.println("=============");
        Student student  = new Student();
        System.out.println(student instanceof Student);
        System.out.println(student instanceof Person);
//        System.out.println(student instanceof Teacher);//编译就报错了
        System.out.println(student instanceof Object);
//        System.out.println(student instanceof String);//编译就报错了；

        System.out.println("=======类型之间的转换============");
        //父类 --> 子类
        //高   -------------低
        Person person1=new Student();
        //将这个person1对象转换为Student类型，我们就可以使用student类型的方法了go()；
        //父类转子类需要强制转换
        // 子类 ------------父类
        Student student1=(Student) person1;
        student1.go();

        //子类转换为父类可能会丢失一些方法，因为有些方法是子类独有的；



    }
}
